(function($){
        function jpPack(){
        Date.prototype.Format = function (fmt) {
            
        var o = {
            "M+": this.getMonth() + 1,
            "d+": this.getDate(),  
            "h+": this.getHours(),  
            "m+": this.getMinutes(),
            "s+": this.getSeconds(), 
            "q+": Math.floor((this.getMonth() + 3) / 3), 
            "S": this.getMilliseconds() 
        };
            if (/(y+)/.test(fmt)) fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
            for (var k in o)
            if (new RegExp("(" + k + ")").test(fmt)) fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
            return fmt;
        }
        this.jpDate=new Date();
        this.jpFullMonthArr=['January','February','March','April','May','June','July','August','September','October','November','December'];
        this.jpMonthArr=['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sept','Oct','Nov','Dec'];
        this.jpCNFullMonthArr=['一月','二月','三月','四月','五月','六月','七月','八月','九月','十月','十一月','十二月'];
        this.jpCNMonthArr=['1月','2月','3月','4月','5月','6月','7月','8月','9月','10月','11月','12月'];
        this.jpFullWeekArr=['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'];
        this.jpWeekArr=['Su','Mo','Tu','We','Th','Fr','Sa'];
        this.jpCNFullWeekArr=['星期日','星期一','星期二','星期三','星期四','星期五','星期六'];
        this.jpCNWeekArr=['日','一','二','三','四','五','六'];
        this.jpYearEffect='none';
        this.jpMonthEffect='none';
        this.jpDateEffect='none';
        this.calEffect='none';
        this.jpIsFullMonth=false;
        this.jpIsFullWeek=false;
        this.jpChangeYearMonth=true;
        this.jpCurYear="";
        this.jpCurMonth="";
        this.jpCurDate="";
        this.jpCurLang="en";
        this.jpCurMonthArr=[];
        this.jpCurWeekArr=[];
        this.jpIndex=0;
        this.isExist=false;
        this.jpOutput=new Object();
        this.isIn=false;
        this.jpWidth=200;
        this.jpHeight=0;
        this.jpDistParent=5;
        this.jpShowPosition="bottom";
        this.isShowTime=false;
        this.jpFormat="";
        
        this.jpDisplayUI=function(){
          this.isExist=true;
          
          var jpUICode='<div class="jpCalendarContent" style="width:'+this.jpWidth+'px;" id="jpCalendarContent'+this.jpIndex+'">\
            <div class="jpTop" id="jpTop'+this.jpIndex+'">\
            <div class="jpSwitch jpLe" id="jpYearMonthDown'+this.jpIndex+'"></div>\
                <div class="jpYearSwitch jpL">\
                  \
                    <div id="jpYearUp'+this.jpIndex+'" class="jpYearUp">&nbsp;</div>\
                    <div id="jpYearDown'+this.jpIndex+'" class="jpYearDown"></div>\
                </div>\
                <div id="jpYear'+this.jpIndex+'" class="jpYear"><div class="jpYScroll"><div class="jpYeartxt cur">0</div></div></div>\
                <div id="jpMonth'+this.jpIndex+'" class="jpMonth"><div class="jpYScroll"><div class="jpMonthtxt cur">0</div></div></div>\
                 <div class="jpYearSwitch jpR">\
                  \
                    <div id="jpYearMonthUp'+this.jpIndex+'" class="jpYearUp">  &nbsp;</div>\
                    <div id="jpYearMonthDown'+this.jpIndex+'" class="jpYearDown"></div>\
                </div>\
                <div class="jpSwitch jpRi" id="jpYearMonthUp'+this.jpIndex+'"></div>\
            </div>\
            <div class="jpMid">\
                <table id="jpWeek'+this.jpIndex+'" class="jpTable jpWeek">\
                     <thead>\
                        <tr>\
                            <td>Mon</td>\
                            <td>Tue</td>\
                            <td>Wed</td>\
                            <td>Thu</td>\
                            <td>Fri</td>\
                            <td>Sat</td>\
                            <td>Sun</td>\
                        </tr>\
                    </thead>\
                </table>\
              \
             </div>\
             <div class="jpBody">\
             <div class="jpYScroll">\
                 <table class="jpTable jpDay" id="jpDay'+this.jpIndex+'">\
                    <tbody>\
                        <tr>\
                            <td><div class="jpDday">0</div><div class="jpMask"></div></td>\
                            <td><div class="jpDday">0</div><div class="jpMask"></div></td>\
                            <td><div class="jpDday">0</div><div class="jpMask"></div></td>\
                            <td><div class="jpDday">0</div><div class="jpMask"></div></td>\
                            <td><div class="jpDday">0</div><div class="jpMask"></div></td>\
                            <td><div class="jpDday">0</div><div class="jpMask"></div></td>\
                            <td><div class="jpDday">0</div><div class="jpMask"></div></td>\
                        </tr>\
                        <tr>\
                            <td><div class="jpDday">0</div><div class="jpMask"></div></td>\
                            <td><div class="jpDday">0</div><div class="jpMask"></div></td>\
                            <td><div class="jpDday">0</div><div class="jpMask"></div></td>\
                            <td><div class="jpDday">0</div><div class="jpMask"></div></td>\
                            <td><div class="jpDday">0</div><div class="jpMask"></div></td>\
                            <td><div class="jpDday">0</div><div class="jpMask"></div></td>\
                            <td><div class="jpDday">0</div><div class="jpMask"></div></td>\
                        </tr>\
                        <tr>\
                            <td><div class="jpDday">0</div><div class="jpMask"></div></td>\
                            <td><div class="jpDday">0</div><div class="jpMask"></div></td>\
                            <td><div class="jpDday">0</div><div class="jpMask"></div></td>\
                            <td><div class="jpDday">0</div><div class="jpMask"></div></td>\
                            <td><div class="jpDday">0</div><div class="jpMask"></div></td>\
                            <td><div class="jpDday">0</div><div class="jpMask"></div></td>\
                            <td><div class="jpDday">0</div><div class="jpMask"></div></td>\
                        </tr>\
                          <tr>\
                            <td><div class="jpDday">0</div><div class="jpMask"></div></td>\
                            <td><div class="jpDday">0</div><div class="jpMask"></div></td>\
                            <td><div class="jpDday">0</div><div class="jpMask"></div></td>\
                            <td><div class="jpDday">0</div><div class="jpMask"></div></td>\
                            <td><div class="jpDday">0</div><div class="jpMask"></div></td>\
                            <td><div class="jpDday">0</div><div class="jpMask"></div></td>\
                            <td><div class="jpDday">0</div><div class="jpMask"></div></td>\
                        </tr>\
                          <tr>\
                            <td><div class="jpDday">0</div><div class="jpMask"></div></td>\
                            <td><div class="jpDday">0</div><div class="jpMask"></div></td>\
                            <td><div class="jpDday">0</div><div class="jpMask"></div></td>\
                            <td><div class="jpDday">0</div><div class="jpMask"></div></td>\
                            <td><div class="jpDday">0</div><div class="jpMask"></div></td>\
                            <td><div class="jpDday">0</div><div class="jpMask"></div></td>\
                            <td><div class="jpDday">0</div><div class="jpMask"></div></td>\
                        </tr>\
                          <tr>\
                            <td><div class="jpDday">0</div><div class="jpMask"></div></td>\
                            <td><div class="jpDday">0</div><div class="jpMask"></div></td>\
                            <td><div class="jpDday">0</div><div class="jpMask"></div></td>\
                            <td><div class="jpDday">0</div><div class="jpMask"></div></td>\
                            <td><div class="jpDday">0</div><div class="jpMask"></div></td>\
                            <td><div class="jpDday">0</div><div class="jpMask"></div></td>\
                            <td><div class="jpDday">0</div><div class="jpMask"></div></td>\
                        </tr>\
                    </tbody>\
                </table>\
            </div>\
            <div id="jpShowTime'+this.jpIndex+'" class="jpShowTime">'+(this.jpDate.getHours()<10?"0"+this.jpDate.getHours():this.jpDate.getHours())+":"+(this.jpDate.getMinutes()<10?"0"+this.jpDate.getMinutes():this.jpDate.getMinutes())+":"+(this.jpDate.getSeconds()<10?"0"+this.jpDate.getSeconds():this.jpDate.getSeconds())+'</div>\
            </div>\
        </div>';
            $(jpUICode).appendTo("body");
            this.jpInitYear();
            this.jpInitMonth();
            this.jpInitWeek();
            this.jpInitDay();
            if(this.jpChangeYearMonth==false){
                this.jpRemoveYearChange();
                this.jpRemoveMonthChange();
            }else{
                this.jpRemoveSwitchL();
                this.jpRemoveSwitchR();
            }
            
           this.jpDisplayPosition(this.jpShowPosition);
           this.jpDisplayTime();
         
        }
        this.jpDisplayTime=function(){
            if(this.isShowTime){
            
                window.setInterval(function(){
                    var date=new Date();
                    
                    $(".jpShowTime").html((date.getHours()<10?"0"+date.getHours():date.getHours())+":"+(date.getMinutes()<10?"0"+date.getMinutes():date.getMinutes())+":"+(date.getSeconds()<10?"0"+date.getSeconds():date.getSeconds()));
                },1000);
            }else{
                this.jpRemoveShowTime();
            }
        }
        this.jpRemoveShowTime=function(){
             $("#jpShowTime"+this.jpIndex).remove();
        }
        this.jpDisplayPosition=function(pos){
           this.jpHeight=$("#jpCalendarContent"+this.jpIndex).height();
          if(pos=="bottom"){
              this.jpShowBottom();
          }else if(pos=="top"){
             this.jpShowTop();
          }else if(pos=="left"){
             this.jpShowLeft();
          }else if(pos=="right"){
             this.jpShowRight();
          }
          
          
        }
        this.jpShowLeft=function(){
          var jpPosY=this.jpOutput.offset().top;
          var jpPosX=this.jpOutput.offset().left;
          var jpParentHeight=this.jpOutput.get(0).offsetHeight;
  
          jpPosY=(jpPosY+jpParentHeight+this.jpDistParent);
          
          var isleft=(parseInt(this.jpWidth)+this.jpDistParent);
             
              if(jpPosX>=isleft){
                   jpPosX=(jpPosX-isleft);
                   if(jpPosY-this.jpHeight/2>=0){
                   jpPosY=jpPosY-this.jpHeight/2;
                   }else{
                       jpPosY=0;
                   }
                   $("#jpCalendarContent"+this.jpIndex).css({"position":"absolute","z-index":"1000","top":jpPosY+"px","left":jpPosX+"px"});
              }else{
                  this.jpShowRight();
              }
               
        }
        this.jpShowRight=function(){
          var jpPosY=this.jpOutput.offset().top;
          var jpPosX=this.jpOutput.offset().left;
        
          var jpParentWidth=this.jpOutput.get(0).offsetWidth;
          
 
           var isright=(parseInt(this.jpWidth)+this.jpDistParent+jpParentWidth+jpPosX);
           var bodyWidth=$("body").width();
       
              if(bodyWidth>=isright){
                  jpPosX=isright-parseInt(this.jpWidth);
                   if(jpPosY-this.jpHeight/2>=0){
                   jpPosY=jpPosY-this.jpHeight/2;
                   }else{
                       jpPosY=0;
                   }
                   $("#jpCalendarContent"+this.jpIndex).css({"position":"absolute","z-index":"1000","top":jpPosY+"px","left":jpPosX+"px"});
              }else{
                 this.jpShowBottom();
              }
               
        }
        this.jpShowTop=function(){
          var jpPosY=this.jpOutput.offset().top;
          var jpPosX=this.jpOutput.offset().left;
        


           var istop=(this.jpDistParent+this.jpHeight);
          
              if(jpPosY>=istop){
                jpPosY=(jpPosY-istop);
              
                $("#jpCalendarContent"+this.jpIndex).css({"position":"absolute","z-index":"1000","top":jpPosY+"px","left":jpPosX+"px"});
              }else{
                  this.jpShowBottom();
              }
              
        }
        this.jpShowBottom=function(){
          var jpPosY=this.jpOutput.offset().top;
          var jpPosX=this.jpOutput.offset().left;
          var jpParentHeight=this.jpOutput.get(0).offsetHeight;
      
          jpPosY=(jpPosY+jpParentHeight+this.jpDistParent);
          $("#jpCalendarContent"+this.jpIndex).css({"position":"absolute","z-index":"1000","top":jpPosY+"px","left":jpPosX+"px"});
        }
        this.jpInitYear=function(){
           var jpYear=this.jpDate.getFullYear();
           this.jpCurYear=jpYear;
           $("#jpYear"+this.jpIndex+" .jpYeartxt").html(jpYear);
        }
        this.jpInitMonth=function(){
            var jpMonthIndex=this.jpDate.getMonth();
           
            $("#jpMonth"+this.jpIndex+" .jpMonthtxt").html(this.jpCurMonthArr[jpMonthIndex]);
            this.jpCurMonth=this.jpCurMonthArr[jpMonthIndex];
        }
        this.jpChangeLanguage=function(lang){
            switch(lang){
                case "cn":
                    if(this.jpIsFullMonth){
                    this.jpCurMonthArr=this.jpCNFullMonthArr; 
                    
                    }else{
                     this.jpCurMonthArr=this.jpCNMonthArr;
                     
                    }
                    if(this.jpIsFullWeek){
                        this.jpCurWeekArr=this.jpCNFullWeekArr;
                    }else{
                        this.jpCurWeekArr=this.jpCNWeekArr;
                    }
                    break;
                case "en":
                    if(this.jpIsFullWeek){
                    this.jpCurMonthArr=this.jpFullMonthArr; 
                   
                    }else{
                     this.jpCurMonthArr=this.jpMonthArr;
                     
                    }
                     if(this.jpIsFullWeek){
                        this.jpCurWeekArr=this.jpFullWeekArr;
                    }else{
                        this.jpCurWeekArr=this.jpWeekArr;
                    }
                    break;
                default:
                    this.jpCurMonthArr=this.jpMonthArr; 
                    this.jpCurWeekArr=this.jpWeekArr; 
                    break;
            }
        }
        this.jpInitWeek=function(){
            var weekindex=0;
            var tmpweek;
            
            tmpweek=this.jpCurWeekArr;
            var tmpisfull=this.jpIsFullWeek;
            this.jpIsFullWeek=true;
            this.jpChangeLanguage(this.jpCurLang);
            var fullweek=this.jpCurWeekArr;
            this.jpIsFullWeek=tmpisfull;
            this.jpChangeLanguage(this.jpCurLang);
            var weektd=$("#jpWeek"+this.jpIndex+" tr td");
           
            $("#jpWeek"+this.jpIndex+" tr td").each(function(){
                $(this).html(tmpweek[weekindex]);
                $(this).attr("title",fullweek[weekindex]);
                weekindex+=1;
            });
            
        }
        this.jpInitDay=function(){
           var maxDay=this.jpGetMaxDayOfDate(this.jpDate.getFullYear(),this.jpDate.getMonth()+1);
           var fromWeek=this.jpGetWeekOfDate(this.jpDate.getFullYear(),this.jpDate.getMonth()+1,1);
           var day=this.jpDate.getDate();
           this.jpCurDate=day;
           var jpindex=0;
        
           $("#jpDay"+this.jpIndex+" tr td").each(function(){
               obj=$(this).find(".jpDday");
               if(jpindex>=fromWeek&&jpindex-fromWeek<maxDay){
                   if(jpindex-fromWeek+1==day){
                       $(this).addClass("jpCurDay");
                   }
                obj.html(jpindex-fromWeek+1);
               }else{
                   obj.html("&nbsp;");
               }
               jpindex+=1;
           });
      
        }
        this.jpDateAnimateEffect=function(effect){
            var obj=$("#jpDay"+this.jpIndex).parent();
            var height=obj.height();
            var width=obj.width();
            switch(effect){
                case "slide":
                 
                    obj.animate({height:"0px"},200).animate({height:"100%"},200);
                   
                    break;
                case "shake":
                 
                     for(var i=1; 7>i; i++){ obj.animate({left:(width-(width/6)*i)*((i%2==0) ? 1:-1)},50-(i*i)) }
                    break;
                case "fade":
                     obj.fadeOut(200);
                     obj.fadeIn(200);
                    break;
                case "scale":
                    
                    obj.animate({height:"0px",width:"0px",left:width/2+"px",top:height/2+"px"},80).animate({height:"100%",width:"100%",left:"0px",top:"0px"},80);
                  
                    break;
            }
        }
        this.jpShowDay=function(year,month){
           this.jpDateAnimateEffect(this.jpDateEffect);
           var maxDay=this.jpGetMaxDayOfDate(year,month+1);
           var fromWeek=this.jpGetWeekOfDate(year,month+1,1);
           var day=this.jpDate.getDate();
           var jpindex=0;
           $("#jpDay"+this.jpIndex+" tr td").each(function(){
               $(this).removeClass("jpCurDay");
               var obj=$(this).find(".jpDday");
               if(jpindex>=fromWeek&&jpindex-fromWeek<maxDay){
                   if(jpindex-fromWeek+1==day){
                       $(this).addClass("jpCurDay");
                   }
                obj.html(jpindex-fromWeek+1);
               }else{
                   obj.html("&nbsp;");
               }
               jpindex+=1;
           });
        }
        this.jpGetMaxDayOfDate=function(year,month){
            return 32-new Date(year,month-1,32).getDate();
        },
        this.jpGetWeekOfDate=function(year,month,day){
            return new Date(year,month-1,day).getDay();
        }
        this.jpBindEvent=function(){
        
            var yeffect=this.jpYearEffect;
            var meffect=this.jpMonthEffect;
            var yaddmethod=this.jpYearAdd;
            var ysubmethod=this.jpYearSub;
            var maddmethod=this.jpMonthAdd;
            var msubmethod=this.jpMonthSub;
            var dclick=this.jpDayClick;
            var obj=this;
            $("#jpYearUp"+this.jpIndex).click(function(){return yaddmethod(yeffect,obj);});
            $("#jpYearDown"+this.jpIndex).click(function(){return ysubmethod(yeffect,obj);});
            $("#jpYearMonthUp"+this.jpIndex).click(function(){return maddmethod(meffect,obj);});
            $("#jpYearMonthDown"+this.jpIndex).click(function(){return msubmethod(meffect,obj);});
            $("#jpDay"+this.jpIndex+" .jpDday").click(function(){return dclick($(this),obj);});
            $("#jpCalendarContent"+this.jpIndex).hover(function(){obj.isIn=true;},function(){obj.isIn=false;});
        }
        this.jpDayClick=function(jpevent,obj){
           
            var day=parseInt(jpevent.html());
            obj.jpRemoveCurDateClass();
            jpevent.parent().addClass("jpCurDay");
            if(day){
                var now=new Date();
                var date=new Date(obj.jpCurYear,obj.jpMonthIndex(obj.jpCurMonth),day,now.getHours(),now.getMinutes(),now.getSeconds()).Format(obj.jpFormat);
              try{
              
                    obj.jpOutput.html(date);
                }catch(ex){

                }
              obj.jpOutput.val(date);
            }
            obj.jpHide();
        }
        this.jpShow=function(){
            $("#jpCalendarContent"+this.jpIndex).fadeIn();
        }
        this.jpRemove=function(){
            this.isExist=false;
            $("#jpCalendarContent"+this.jpIndex).remove();
        }
        this.jpHide=function(){
          
           $("#jpCalendarContent"+this.jpIndex).fadeOut();
        }
        this.jpYearAdd=function(effect,obj){
           var year=parseInt($("#jpYear"+obj.jpIndex+" .cur").html())+1;
           obj.jpCurYear=year;
           obj.jpUseEffect("jpYear"+obj.jpIndex,"add",effect,year-1,year);
           var i=obj.jpMonthIndex(obj.jpCurMonth);
           obj.jpShowDay(year,i);
        }
        this.jpYearSub=function(effect,obj){
           var year=parseInt($("#jpYear"+obj.jpIndex+" .cur").html())-1;
           obj.jpCurYear=year;
           obj.jpUseEffect("jpYear"+obj.jpIndex,"sub",effect,year+1,year);
          
           var i=obj.jpMonthIndex(obj.jpCurMonth);
           obj.jpShowDay(year,i);
        }
        this.jpUseEffect=function(id,method,effect,curval,nextval){
      
            switch(effect){
               case 'slide':
                   if(method=='add'){
                       this.jpAddSlide(id,curval,nextval);
                   }else if(method=='sub'){
                       this.jpSubSlide(id,curval,nextval);
                   }
                   break;
               case 'none':
                  this.jpNoneEffect(id,nextval);
                   break;
               case 'move':
                   if(method=='add'){
                        this.jpAddMove(id,curval,nextval);
                   }else if(method=='sub'){
                       this.jpSubMove(id,curval,nextval);
                   }
                   break;
               case 'fade':
                   this.jpFadeEffect(id,curval,nextval);
                   break;
               case 'shake':
                   this.jpShakeEffect(id,nextval);
                   break;
           }
           this.jpOutput.focus();
          
            
        }
        this.jpShakeEffect=function(jpid,nextval){
            var width=$("#"+jpid).width();
            var height=$("#"+jpid).get(0).offsetHeight;
            $("#"+jpid+" .jpYScroll").css({"width":width+"px","height":height+"px"});
            var cur=$("#"+jpid+" .cur");
            cur.css({"width":width+"px","height":height+"px","display":"block","position":"absolute","z-index":1,"top":"0px","left":"0px"});
            for(var i=1; 7>i; i++){ cur.animate({left:(width-(width/6)*i)*((i%2==0) ? 1:-1)},50-(i*i)) }
            cur.html(nextval);
            
        }
        this.jpFadeEffect=function(jpid,jpval1,jpval2){
    
            var width=$("#"+jpid).width();
            var height=$("#"+jpid).get(0).offsetHeight;
            var cur=$("#"+jpid+" .cur");
            var jpYScroll_div=$("#"+jpid+" .jpYScroll div");
            $("#"+jpid+" .jpYScroll").css({"width":width+"px","height":height+"px"});
            if(jpYScroll_div.length<2){
                      next=$("<div class='jpYeartxt jpnext'>"+jpval2+"</div>");
                      cur.before(next);
             }
           
            next=$("#"+jpid+" .jpnext");
            cur.width(width);
            next.width(width);
            cur.html(jpval1);
            next.html(jpval2);

            
            cur.css({"display":"block","position":"absolute","z-index":1,"top":"0px","left":"0px"});
            next.css({"display":"block","position":"absolute","z-index":0,"top":"0px","left":"0px"});
          
            cur.fadeOut("fast",function(){
                 $(this).css({"z-index":0});
                 $(this).parent().find(".cur").css({"z-index":1});
                 
            });
             jpYScroll_div.removeClass("cur");
             cur.addClass("jpnext");
             next.removeClass("jpnext");
             next.addClass("cur");
         
        }
        this.jpSubMove=function(jpid,jpval1,jpval2){

                  var next;
                  var width=$("#"+jpid).width();
                  var cur=$("#"+jpid+" .cur");
                  var jpYScroll_div=$("#"+jpid+" .jpYScroll div");
                  var jpYScroll=$("#"+jpid+" .jpYScroll");
                  jpYScroll.css({"width":width*2+"px","left":"-"+width+"px"});
                  if(jpYScroll_div.length<2){
                      next=$("<div class='jpYeartxt jpnext'>"+jpval2+"</div>");
                      cur.before(next);
                  }
                 
                  next=$("#"+jpid+" .jpnext");
                  jpYScroll_div.css({"float":"left","width":width+"px"});
                  cur.before(next);
                  cur.html(jpval1);
                  next.html(jpval2);
                  jpYScroll.animate({left:"0px"},"fast",function(){
                     $(this).css("left",-width+"px");
                     next.before(cur);
                  });
                  
                  jpYScroll_div.removeClass("cur");
                  cur.addClass("jpnext");
                  next.removeClass("jpnext");
                  next.addClass("cur");
                 
        }
        this.jpAddMove=function(jpid,jpval1,jpval2){
          
                  var next;
                  var width=$("#"+jpid).width();
                  var cur=$("#"+jpid+" .cur");
                  var jpYScroll=$("#"+jpid+" .jpYScroll");
                  var jpYScroll_div=$("#"+jpid+" .jpYScroll div");
                  jpYScroll.css({"width":2*width+"px","left":"0px"});
                  if(jpYScroll_div.length<2){
                      next=$("<div class='jpYeartxt jpnext'>"+jpval2+"</div>");
                      cur.after(next);
                  }
                  
                  next=$("#"+jpid+" .jpnext");
                  jpYScroll_div.css({"float":"left","width":width+"px"});
                  cur.after(next);
                  cur.html(jpval1);
                  next.html(jpval2);
                  jpYScroll.animate({left:"-"+width+"px"},"fast",function(){
                     $(this).css("left","0px");
                     next.after(cur);
                  });
                  
                  jpYScroll_div.removeClass("cur");
                  cur.addClass("jpnext");
                  next.removeClass("jpnext");
                  next.addClass("cur");
         
        }
        this.jpNoneEffect=function(jpid,jpnextval){ //直接显示
                  var cur=$("#"+jpid+" .cur");
                  cur.css("position","relative");
                  var next=$("<div class='jpnext'>"+jpnextval+"</div>");
                  next.css("position","relative");
                  $("#"+jpid+" .cur").last().after(next);
                  next.addClass("cur");
                  cur.remove();
        },
        this.jpAddSlide=function(jpid,jpval1,jpval2){//上下滚动
               
                  var next;
                  var myobj=$("#"+jpid);
                  var width=myobj.width();
                  var cur=$("#"+jpid+" .cur");
                  var jpYScroll=$("#"+jpid+" .jpYScroll");
                  var jpYScroll_div=$("#"+jpid+" .jpYScroll div");
                  var pheight=myobj.get(0).offsetHeight;
                  if(jpYScroll_div.length<2){
                      next=$("<div class='jpYeartxt jpnext'>"+jpval2+"</div>");
                      cur.after(next);
                  }
                
                 
                  next=$("#"+jpid+" .jpnext");
                  cur.after(next);
                  cur.height(pheight);
                  next.height(pheight);
                  jpYScroll.css("top","0px");
                  jpYScroll_div.css({"width":width+"px"});
                  var height=cur.height();
                  
                  cur.html(jpval1);
                  next.html(jpval2);
                  jpYScroll.animate({top:"-"+height+"px"},"fast",function(){
                     $(this).css("top","0px");
                     next.after(cur);
                  });
                  
                   jpYScroll_div.removeClass("cur");
                   cur.addClass("jpnext");
                   next.removeClass("jpnext");
                   next.addClass("cur");
                 
        }
        this.jpSubSlide=function(jpid,jpval1,jpval2){//上下滚动
           
                  var next;
                  var myobj=$("#"+jpid);
                  var width=myobj.width();
                  var cur=$("#"+jpid+" .cur");
                  var jpYScroll=$("#"+jpid+" .jpYScroll");
                  var jpYScroll_div=$("#"+jpid+" .jpYScroll div");
                  var pheight=myobj.get(0).offsetHeight;
                  if(jpYScroll_div.length<2){
                      next=$("<div class='jpYeartxt jpnext'>"+jpval2+"</div>");
                      cur.before(next);
                  }
                 
                  next=$("#"+jpid+" .jpnext");
                  cur.height(pheight);
                  next.height(pheight);
                  next.after(cur);
                  var height=next.height();
                  jpYScroll_div.css({"width":width+"px"});
                  jpYScroll.css("top","-"+height+"px");
                  cur.html(jpval1);
                  next.html(jpval2);
                  jpYScroll.animate({top:"0px"},"fast",function(){
                     $(this).css("top","-"+height+"px");
                     cur.after(next);
                  });
                  
                   jpYScroll_div.removeClass("cur");
                   cur.addClass("jpnext");
                   next.removeClass("jpnext");
                   next.addClass("cur");
                
        }
        this.jpMonthAdd=function(effect,obj){
  
           var jpmonth=$("#jpMonth"+obj.jpIndex+" .cur").html();
           var montharr;
          
           montharr=obj.jpCurMonthArr;
            
           var i=obj.jpMonthIndex(jpmonth);
           var j=0;
           if(i+1>11){
               j=0;
               obj.jpCurMonth=montharr[j];
               obj.jpYearAdd(obj.jpYearEffect,obj);
           }else{
              j=i+1; 
              obj.jpCurMonth=montharr[j];
              obj.jpShowDay(obj.jpCurYear,j);
           }
          obj.jpUseEffect("jpMonth"+obj.jpIndex,"add",effect,montharr[i],montharr[j]);
         
          
        }
        this.jpMonthIndex=function(str_month){
            var montharr;
           
            montharr=this.jpCurMonthArr;
            
           
            
            for(var i=0;i<montharr.length;i++){
                if(montharr[i]==str_month){
                    return i;
                }
            }
            return -1;
        }
        this.jpMonthSub=function(effect,obj){
           var jpmonth=$("#jpMonth"+obj.jpIndex+" .cur").html();
           var montharr;
         
                 montharr=obj.jpCurMonthArr;
            
           var i=obj.jpMonthIndex(jpmonth);
           var j=0;
           if(i-1<0){
               j=11;
               obj.jpCurMonth=montharr[j];
               obj.jpYearSub(obj.jpYearEffect,obj);
           }else{
              j=i-1;    
              obj.jpCurMonth=montharr[j];
              obj.jpShowDay(obj.jpCurYear,j);
           }
         obj.jpUseEffect("jpMonth"+obj.jpIndex,"sub",effect,montharr[i],montharr[j]);
        
        }
        this.jpRemoveYearChange=function(){
            $("#jpTop"+this.jpIndex+" .jpL").remove();
        }
        this.jpRemoveMonthChange=function(){
            $("#jpTop"+this.jpIndex+" .jpR").remove();
        }
        this.jpRemoveSwitchL=function(){
            $("#jpTop"+this.jpIndex+" .jpLe").remove();
        }
        this.jpRemoveSwitchR=function(){
            $("#jpTop"+this.jpIndex+" .jpRi").remove();
        }
        this.jpRemoveCurDateClass=function(){
          
            $("#jpDay"+this.jpIndex+" .jpCurDay").removeClass("jpCurDay");
        }
        this.jpUserTheme=function(theme){
            switch(theme){
                case "default":
                    this.jpIncludeCss("css/jpcalendar.css");
                    break;
                case "black":
                    this.jpIncludeCss("css/jpcalendarb.css");
                    break;
                case "gray":
                    this.jpIncludeCss("css/jpcalendarg.css");
                    break;
                case "yellow":
                    this.jpIncludeCss("css/jpcalendary.css");
                    break;
                case "violet":
                    this.jpIncludeCss("css/jpcalendarz.css");
                    break;
                case "red":
                    this.jpIncludeCss("css/jpcalendarr.css");
                    break;
            }
        }
        this.jpIncludeCss=function(csspath){
            	var head = document.getElementsByTagName('head')[0];
                var link = document.createElement('link');
                link.href = csspath;
                link.rel = 'stylesheet';
                link.type = 'text/css';
                head.appendChild(link);
        }
        
        
        
    }
    
    var jpObjectCount=0;
    
    $.fn.jpCalendar=function(option){
     
        var settings={
          
            changeYearMonth:false,
            showCurDate:true,
            calEffect:'slide',
            yearEffect:'slide',
            monthEffect:'slide',
            dateEffect:'scale',
            jpIsFullMonth:false,
            jpIsFullWeek:false,
            lang:"en",
            width:"200",
            position:"bottom",
            isShowTime:true,
            Format:"yyyy-MM-dd"
        };
        var jpP=new jpPack();
        return this.each(function(){
            if(option){
                $.extend(settings,option);
            }
            jpP.jpUserTheme(settings.theme);
            jpObjectCount+=1;
            jpP.jpIndex=jpObjectCount;
            jpP.jpIsFullMonth=settings.jpIsFullMonth;
            jpP.jpIsFullWeek=settings.jpIsFullWeek;
            jpP.jpCurLang=settings.lang;
            jpP.jpChangeLanguage(settings.lang);
            jpP.jpChangeYearMonth=settings.changeYearMonth;
            jpP.jpWidth=settings.width;
            jpP.jpShowPosition=settings.position;
            jpP.isShowTime=settings.isShowTime;
            jpP.jpFormat=settings.Format;
            if(settings.showCurDate==false){
                jpP.jpRemoveCurDateClass();
            }
            if(settings.yearEffect){
                jpP.jpYearEffect=settings.yearEffect;
            }
            if(settings.calEffect){
                jpP.calEffect=settings.calEffect;
            }
            if(settings.monthEffect){
                jpP.jpMonthEffect=settings.monthEffect;
            }
            if(settings.dateEffect){
                jpP.jpDateEffect=settings.dateEffect;
            }
            
            
            
            
          
            
            jpP.jpOutput=$(this);
          
        
                
                
                
            if($(this).is("input")){
            $(this).blur(function(){
                if(jpP.isExist&&!jpP.isIn){
                    jpP.jpHide();
                }
            });
            
            $(this).focus(function(){
                if(!jpP.isExist){
                jpP.jpDisplayUI();
                jpP.jpBindEvent();
                }else{
                    jpP.jpShow();
                }
            
                
            });
        }else{
            $(this).click(function(){
                if(!jpP.isExist){
                jpP.jpDisplayUI();
                jpP.jpBindEvent();
                }else{
                    jpP.jpShow();
                }
            });
        }
      
          
            
        });
    }
   
})(jQuery);